{extend name="layout/base"}

{block name="content"}
<div class="layui-form layui-form-pane">
    <div class="layui-tab">
        <div class="layui-tab-content category_content">
            <div class="layui-tab-item layui-show">
                <input type="hidden" name="cid" value="{$data.cate_id}">

                <div class="layui-form-item">
                    <label class="layui-form-label">栏目名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="cate_name" value="{$data.cate_name}" class="layui-input" placeholder="栏目名称" required>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属栏目</label>
                    <div class="layui-input-block">
                        <select name="cate_pid" class="layui-input">
                            <option value="0">顶级栏目</option>
                            {foreach $lists as $key=>$value }
                                <option value="{$value.cate_id}" {if $data.cate_pid == $value.cate_id }selected = "selected"{/if}>{$value.html}{$value.cate_name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">链接</label>
                    <div class="layui-input-block">
                        <input type="text" name="cate_url" class="layui-input" value="{$data.cate_url}" placeholder="url地址" required>
                    </div>
                </div>
                <div class="layui-form-item" pane>
                    <label class="layui-form-label">是否显示</label>
                    <div class="layui-input-block">
                        <input type="radio" name="cate_status" {if $data.cate_status ==1}checked value="{$data.cate_status}"{else /}value="1"{/if}  title="是">
                        <input type="radio" name="cate_status" {if $data.cate_status ==0}checked value="{$data.cate_status}"{else /}value="0"{/if}  title="否">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button lay-filter="add" lay-submit class="layui-btn layui-btn-sm">提交</button>
        </div>
    </div>
</div>
<script>
    layui.use(['jquery', 'form', 'element'], function ($, form, element) {
        form.on('submit(add)', function (obj) {
            $.post({
                url: "{:url('')}",
                data: obj.field,
                success: function(res){
                    layer.msg(res.msg, {
                        icon: res.code ===0 ? 6: 5
                    });
                    parent.location.reload()
                }
            });
            return false;
        });
        
    });
</script>
{/block}